/* 让文本的光标停留在文字的最前面，来自：
		http://programanddesign.com/js/jquery-select-text-range/*/
		$.fn.selectRange = function(start, end) {
			return this.each(function() {
				if(this.setSelectionRange) {
					this.focus();
					this.setSelectionRange(start, end);
				} else if(this.createTextRange) {
					var range = this.createTextRange();
					range.collapse(true);
					range.moveEnd('character', end);
					range.moveStart('character', start);
					range.select();
				}
			});
		};

		
		/*添加回复*/
		$('#comment_list li .reply').live('click',function(){
			$('#comment_content').val($(this).attr('lang')).focus().selectRange(0,0);
			return false;
		})
		
		
		/*回复列表 ajax翻页*/
		$('#comment_list .pagination a').live('click',function(){
					
					$("#comment_list").html('在努力的加载中..');
					var url = $(this).attr('href');
					$.get(url, function(result){
						$("#comment_list").html(result).fadeIn();
					  });
					return false;
				})
		
		
		/*还可以输入xx 个字符*/
		function checkLength(obj, name, max)
		{
			var maxChars = max;
			var ch_length = obj.value.length;
			for(var i=Math.floor(maxChars/2); i<ch_length; i++)
			{
				var content = obj.value.substring(0,i);
				if(content.replace(/([\u0391-\uFFE5])/ig,'111').length>=maxChars)
				{
					obj.value = obj.value.substring(0,i);
					document.getElementById("ls_"+name).innerHTML = curr.toString(0);
					break;
				}
			}
			test = obj.value.replace(/([\u0391-\uFFE5])/ig,'111');
			var curr = maxChars - test.length; 
			document.getElementById("ls_"+name).innerHTML = curr.toString();
		}
		
		
		
		$().ready(function() {
			 // $('#comment_form').checkForm(1);
		});